package org.hismig.test.migration;

import java.util.concurrent.ExecutionException;

import org.hismig.cfg.Configuration;
import org.hismig.migration.Constructor;
import org.hismig.migration.Context;
import org.hismig.migration.executor.ext.IExtExecutor;
import org.hismig.migration.result.ResultInfo;

import junit.framework.TestCase;

/**
 * @declare: //TODO <br />
 *           This class created by Vansion.Hopihit on 2012-07-04 <br />
 *           <a href="mailto:vansionhopihit@gmail.com">Contact Me</a>
 * @version 1.0
 * @author Vansion.Hopihit
 * 
 */
public class TableExtExecutorTester extends TestCase {

	private Constructor constructor;

	@Override
	protected void setUp() throws Exception {
		Configuration configuration = new Configuration(ConstructorTester.class
				.getResource("HisMig.cfg.xml").toURI());
		constructor = new Constructor();
		constructor.init(configuration);
	}

	public void testSourceDBPreExtExecutor() throws ExecutionException {
		IExtExecutor extExecutor = constructor.getDbExecutors().get(0)
				.getTableExecutors().get(0).getSourcePreExtExecutor();
		ResultInfo resultInfo = extExecutor.execute(new Context());

		assertTrue(resultInfo.getExceptions().isEmpty());
	}
	public void testDistDBPreExtExecutor() throws ExecutionException {
		IExtExecutor extExecutor = constructor.getDbExecutors().get(0)
				.getTableExecutors().get(0).getDistPreExtExecutor();
		ResultInfo resultInfo = extExecutor.execute(new Context());

		assertTrue(resultInfo.getExceptions().isEmpty());
	}

	public void testDistDBAfterExtExecutor() throws ExecutionException {
		IExtExecutor extExecutor = constructor.getDbExecutors().get(0)
				.getTableExecutors().get(0).getDistAfterExtExecutor();
		ResultInfo resultInfo = extExecutor.execute(new Context());

		assertTrue(resultInfo.getExceptions().isEmpty());

	}

	public void testSourceDBAfterExtExecutor() throws ExecutionException {
		IExtExecutor extExecutor = constructor.getDbExecutors().get(0)
				.getTableExecutors().get(0).getSourceAfterExtExecutor();
		ResultInfo resultInfo = extExecutor.execute(new Context());

		assertTrue(resultInfo.getExceptions().isEmpty());
	}
}
